package com.jy.adscm.operation.mail.controller;

import com.jy.adscm.annotation.AdscmLogger;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.cg.bean.CgTask;
import com.jy.adscm.operation.mail.bean.MailBean;
import com.jy.adscm.operation.mail.utils.MailUtil;
import com.jy.adscm.security.utils.Token;
import com.jy.adscm.support.SimpleCoreResponse;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * @author zyl
 * @Date 2019/7/23 -11:20
 */
@RestController
@RequestMapping("adscm/operation/mail")
public class MailController {

    @Autowired
    RedisTemplate<Object, Token> tokenRedisTemplate;
    @Autowired
    MailUtil mailUtil;
    /**
     * 发送邮件
     * @param cgTask
     * @param request
     * @return
     * @throws AdscmSystemException
     */
    @RequestMapping("send/{id}")
    public SimpleCoreResponse update(@RequestBody CgTask cgTask, HttpServletRequest request) throws AdscmSystemException {
        String tokenId = request.getParameter("tokenId");
        MailBean mailBean=MailBean.getMailBean();
        mailBean.setReceiver("862247907@qq.com");
        mailBean.setText("测试一下");
        mailBean.setSubject("你好啊");
        mailUtil.sendMailHtml(mailBean);
        return  new SimpleCoreResponse("200","发送成功","");
    }
}
